package br.great.multimidia;

import br.great.beans.*;
import br.great.config.FacebookData;
import br.great.config.PhotomapConstants;
import br.great.functionalCore.*;
import com.mapia.Json.JSONException;
import com.restfb.FacebookToken;
import com.restfb.TokenFile;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.sanselan.ImageReadException;
import org.apache.sanselan.ImageWriteException;

public class Principal implements Runnable {

	final static ArrayList<TagsData> tagsData = new ArrayList<TagsData>();
	static ArrayList<PhotoIPTC> photoIPTC = new ArrayList<PhotoIPTC>();
	static ArrayList<Boolean> ready = new ArrayList<Boolean>();
	static ArrayList<Photo> contextPhoto = new ArrayList<Photo>();
	static ArrayList<Photo> currentPhoto = new ArrayList<Photo>();
	static ArrayList<File> selectedFile = new ArrayList<File>();
	static ArrayList<ArrayList<String>> wordsHigh = new ArrayList<ArrayList<String>>();
	static ArrayList<ArrayList<String>> wordsMedium = new ArrayList<ArrayList<String>>();
	static ArrayList<Boolean> blHigh = new ArrayList<Boolean>();
	static ArrayList<Boolean> blMedium = new ArrayList<Boolean>();
	static ArrayList<ImageIcon> imageIcon25 = new ArrayList<ImageIcon>();
	static ArrayList<ImageIcon> imageIconSlider = new ArrayList<ImageIcon>();
	static ArrayList<ImageIcon> imageIcon75 = new ArrayList<ImageIcon>();
	static ArrayList<Precision> highPrecision = new ArrayList<Precision>();
	static ArrayList<Precision> mediumPrecision = new ArrayList<Precision>();
	static int size = 0;
	static int value = 0;
	final static String name = "Tales";

	public static void main(String[] args) throws ImageReadException, IOException, ImageWriteException, FileNotFoundException, ParseException, JSONException {

//		for (int i = 1; i < 3; i++) {
//			File file = new File("/home/talespf/mestrado/context_picasa/Album_1/Album_1_" + i + ".jpg");
//			selectedFile.add(file);
//		}

		// for(int i=1; i < 3; i++){
		// File file = new
		// File("C:/Users/Drazzco/Desktop/Arquivos/album1/Album_1/Album_1_" + i
		// + ".jpg");
		// selectedFile.add(file);
		// }
		
		// Utiliza-se quando a aplicação esta sendo executada recebendo paths de fotos do picasa
		for (int i = 0; i < args.length; i++) {
			File file = new File(args[i]);
			selectedFile.add(file);
		}

		String devices = "";

		boolean deleteToken = false;

		size = selectedFile.size();

		for (int i = 0; i < selectedFile.size(); i++) {
			ready.add(false);
		}

		// Utiliza-se quando a aplicação esta sendo executada recebendo um path de uma foto do picasa
		// File selectedFile = new File(args[0]);

		// Pega o caminho da foto
		ArrayList<String> uriPhoto = new ArrayList<String>();
		for (int i = 0; i < selectedFile.size(); i++) {
			uriPhoto.add(selectedFile.get(i).getPath());
		}

		// Utiliza o caminho da foto para encontrar o arquivo owl(o arquivo que
		// contem a ontologia e tem o mesmo nome da foto)
		ArrayList<String> uriPhotoAnnotation = new ArrayList<String>();
		for (int i = 0; i < selectedFile.size(); i++) {
			uriPhotoAnnotation.add(uriPhoto.get(i).replaceAll(".jpg", ".owl"));
		}
		// Teste
		// System.out.println("uriPhoto: " + uriPhoto);
		// String uriOntologia = selectedFile.getPath();

		// Cria uma nova foto

		// Seta essa foto com o uri da Foto passada como parametro(a que o
		// usuario escolheu no JFile Choose)

		for (int i = 0; i < selectedFile.size(); i++) {
			Photo photo = new Photo();
			photo.setURIPhoto(uriPhoto.get(i));
			photo.setURIAnnotations(uriPhotoAnnotation.get(i));
			currentPhoto.add(photo);
		}

		// Seta onde esta o owl correspondente da foto
		// currentPhoto.setURIAnnotations(uriPhotoAnnotation);

		// Criar uma PhotoIPTC - Componente para adicionar tags
		// PhotoIPTC photoIPTC = new PhotoIPTC(selectedFile);

		// Teste
		// System.out.println("O URI da Foto eh: " +
		// currentPhoto.getURIPhoto());
		// System.out.println("O URI do OWL eh: " +
		// currentPhoto.getURIAnnotations());

		// Cria um PhotoCreator
		// PhotoCreator pc = new PhotoCreator();

		// Cria uma ontologia
		// pc.createPhoto(currentPhoto.get(0), 0);
		for (int i = 0; i < selectedFile.size(); i++) {
			PhotoCreator pc = new PhotoCreator();
			Photo photo = pc.createPhoto(currentPhoto.get(i), 0);
			contextPhoto.add(photo);
		}

		// ************** FACEBOOK ********************//

		// String at = TokenFile.getText(name);
		// // Verifica se o arquivo Token.txt existe
		// if (at == null) {
		// // Faz o primeiro acesso ao Facebook para recuperar o código de
		// // verificação
		// FacebookToken.firstAccess(name);
		// ObtainsFriendInference obf = new ObtainsFriendInference();
		// SaveFacebookInstances sfi = new SaveFacebookInstances();
		// // Salva os dados do Facebook em arquivos txt (FacebookName.txt,
		// // FacebookBluetooth.txt, FacebookBirthday.txt)
		// sfi.saveFacebookInstances(obf, name);
		// }
		//
		// // Verifica se o usuário quer atualizar os dados de seus amigos do
		// // Facebook
		// Scanner sc = new Scanner(System.in);
		// System.out.println(PhotomapConstants.WHENUPDATEFRIENDS);
		// System.out.print(PhotomapConstants.UPDATEFRIENDS);
		// int updateFriends = sc.nextInt();
		// if (updateFriends == 1) {
		// // Deleta os arquivos txt dos dados
		// boolean fname = false, fblue = false, fbirth = false;
		// try {
		// fname = FacebookData.deleteFacebookName(name);
		// fblue = FacebookData.deleteFacebookBluetooth(name);
		// fbirth = FacebookData.deleteFacebookBirthday(name);
		// } catch (IllegalArgumentException e) {
		// deleteToken = FacebookData.deleteFacebookToken(name);
		// }
		// if (deleteToken == true) {
		// // Faz o primeiro acesso ao Facebook para recuperar o código de
		// // verificação
		// FacebookToken.firstAccess(name);
		// ObtainsFriendInference obf = new ObtainsFriendInference();
		// SaveFacebookInstances sfi = new SaveFacebookInstances();
		// // Salva os dados do Facebook em arquivos txt (FacebookName.txt,
		// // FacebookBluetooth.txt, FacebookBirthday.txt)
		// sfi.saveFacebookInstances(obf, name);
		// } else {
		// // Se os 3 arquivos tiverem sido deletados
		// if (fname == fblue == fbirth == true) {
		// ObtainsFriendInference obf = new ObtainsFriendInference();
		// SaveFacebookInstances sfi = new SaveFacebookInstances();
		// sfi.saveFacebookInstances(obf, name);
		// } else {
		// System.out.println(PhotomapConstants.UPDATEFRIENDSERROR);
		// }
		//
		// }
		// }

		// ************** FACEBOOK ********************//

		// Converter o formato da data
		tagsData.add(inference(0, name));

		InterfaceTeste it2 = new InterfaceTeste();

		for (int i = 0; i < 12; i++) {
			blHigh.add(true);
			blMedium.add(false);
		}

		it2.setValidateHigh(blHigh);
		it2.setValidateMedium(blMedium);

		for (int i = 0; i < selectedFile.size(); i++) {
			BufferedImage thumb = Thumbnails.of(selectedFile.get(i)).scale(1)
					.asBufferedImage();
			int w = thumb.getWidth();
			double weight = w / 102.4;
			ImageIcon ic = new ImageIcon(Thumbnails.of(selectedFile.get(i))
					.scale(1 / weight).asBufferedImage());
			imageIcon25.add(ic);
			imageIconSlider.add(ic);
			weight = w / 512;
			ic = new ImageIcon(Thumbnails.of(selectedFile.get(i))
					.scale(1 / weight).asBufferedImage());
			imageIcon75.add(ic);
		}

		it2.setIcon25(imageIcon25);
		it2.setIcon75(imageIcon75);
		it2.setIconSlider(imageIconSlider);
		it2.setCounter(0);
		it2.setIconjLabel4(imageIcon75.get(0));
		it2.setVality(ready);
		it2.setSliderValue(0);

		setarFotos(it2, imageIcon25);

		setarFotosSlider(it2, imageIcon25, 0);

		ordenar(highPrecision, mediumPrecision, 0);

		setarTags(it2, highPrecision, mediumPrecision);

		setarWords(highPrecision, mediumPrecision);

		it2.setVisible(true);

		Thread t = new Thread(new Principal());
		t.start();

		// java.awt.EventQueue.invokeLater(new Runnable() {
		// public void run() {
		// }
		// });

		// ArrayList<String> tags = tagsData.getValues();
		// Adicionar ao IPTC da foto as informações que foram lidas da
		// ontologia
		// photoIPTC.addIPTCKeyword(tagsData);
		// photoIPTC.addIPTCKeyword(country,city, dateString, latitude,
		// longitude, partOfDay, sunLight, temperatura);
		// for(int i=0; i < tags.size(); i++)
		// {
		// System.out.println("Tags: " + tags.get(i));
		// photoIPTC.addIPTCKeyword(tags.get(i));
		// }
		// Testes
		// String tagName = JOptionPane
		// .showInputDialog("Tag name to be added to the image:");
		// photoIPTC.addIPTCKeyword("teste");

	}

	public static TagsData inference(int i, String name)
			throws ImageReadException, IOException, FileNotFoundException,
			ParseException, JSONException, ImageWriteException {
		SeePhoto sp = new SeePhoto();

		TagsData td = new TagsData();
		PossibleTag pt = new PossibleTag();
		ArrayList<PossibleTag> apt;

		// Ler a Ontologia
		sp.openPhoto(contextPhoto.get(i), 0);

		DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);

		// Dados de Contexto - Horario da Foto
		String dateString = df.format(currentPhoto.get(i).getDateTime());

		System.out.println("Data: " + dateString);

		// Dados de Contexto - Temperatura
		String temperatura = Double.toString(currentPhoto.get(i)
				.getTemperature().getValue());
		pt.setPrecision(1);
		pt.setSufix("TIME");
		pt.setValue(temperatura);
		td.setTemperature(pt);
		pt = new PossibleTag();

		// Dados de Contexto - Horario da Latitude
		String latitude = Double.toString(currentPhoto.get(i).getCoor()
				.getLatitude());
		double latitude2 = currentPhoto.get(i).getCoor().getLatitude();
		// Dados de Contexto - Longitude
		String longitude = Double.toString(currentPhoto.get(i).getCoor()
				.getLongitude());
		double longitude2 = currentPhoto.get(i).getCoor().getLongitude();

		// Capturar e Imprimir o metadados contextuais
		ArrayList<String> possibleTags = new ArrayList<String>();

		String day = null;
		String hour = null;
		if (currentPhoto.get(i).getDateTime() != null) {
			ArrayList<Integer> k = new ArrayList<Integer>();
			k.add(currentPhoto.get(i).getDateTime().getDate());
			k.add(currentPhoto.get(i).getDateTime().getMonth() + 1);
			k.add(currentPhoto.get(i).getDateTime().getYear() + 1900);
			k.add(currentPhoto.get(i).getDateTime().getHours());
			k.add(currentPhoto.get(i).getDateTime().getMinutes());
			k.add(currentPhoto.get(i).getDateTime().getSeconds());
			day = k.get(0).toString() + "/" + k.get(1).toString() + "/"
					+ k.get(2).toString();
			hour = k.get(3).toString() + ":" + k.get(4).toString() + ":"
					+ k.get(5).toString();
			System.out.println("Dia da Foto: "
					+ currentPhoto.get(i).getDateTime());

			pt.setPrecision(1);
			pt.setSufix("TIME");
			pt.setValue(day);
			td.setDay(pt);
			pt = new PossibleTag();

			pt.setPrecision(1);
			pt.setSufix("TIME");
			pt.setValue(hour);
			td.setHour(pt);
			pt = new PossibleTag();

		}
		if (currentPhoto.get(i).getTemperature() != null) {
			ArrayList<Float> k = new ArrayList<Float>();
			k.add(currentPhoto.get(i).getTemperature().getValue());
			possibleTags.add(k.get(0).toString());
			System.out.print("Temperatura: "
					+ currentPhoto.get(i).getTemperature().getValue());
			if (currentPhoto.get(i).getTemperature().getType() != null) {
				System.out.println(" "
						+ currentPhoto.get(i).getTemperature().getType()
								.substring(0, 1));
			}
		}
		if (currentPhoto.get(i).getCoor() != null) {
			System.out.println("Coordenadas - " + "Latitude: "
					+ currentPhoto.get(i).getCoor().getLatitude()
					+ " Longitude: "
					+ currentPhoto.get(i).getCoor().getLongitude());

		}
		String devices = "";
		if (currentPhoto.get(i).getDevices() != null) {
			Iterator itDev = currentPhoto.get(i).getDevices().iterator();
			while (itDev.hasNext()) {
				devices += (String) itDev.next() + ", ";
			}
			System.out.println("Dispositivos Proximos: " + devices);
		}

		if (currentPhoto.get(i).getWeather() != null) {
			if (currentPhoto.get(i).getWeather().getDescription() != null) // System.out.println("inside of weather description:"+currentPhoto.getWeather().getDescription());
			{
				possibleTags.add(currentPhoto.get(i).getWeather()
						.getDescription());
				pt.setPrecision(1);
				pt.setSufix("WEATHER");
				pt.setValue(currentPhoto.get(i).getWeather().getDescription());
				td.setWeather(pt);
				pt = new PossibleTag();
				System.out.println("Tempo: "
						+ currentPhoto.get(i).getWeather().getDescription());

			}
		}

		// CHAMNDO METDODOS DE GERACAO DE NOVAS INFORMACOES

		AnnotationGenerator ag = new AnnotationGenerator();
		try {
			ag.interpretationPhoto(currentPhoto.get(i));
		} catch (NullPointerException ex) {
			System.out.println("Null aqui");
		}

		// ArrayList<PossibleTag> createPossibleTag = new
		// ArrayList<PossibleTag>();

		// *************** FACEBOOK *********************//

		// FriendInference friendInference = new FriendInference(name);
		// // createPossibleTag recebe os PossibleTags gerados para a foto
		// // específica.
		// apt = friendInference.generateTagsFromFacebookPT(currentPhoto.get(i)
		// .getDateTime(), currentPhoto.get(i).getDevices());
		//
		// int poss = apt.size();
		//
		// // ArrayList<String> friends = new ArrayList<String>();
		// // Para todos os PossibleTags em createPossibleTag,
		// // os que tiverem precisão acima de 0.5 serão adicionados na lista
		// value
		// // e os elementos de value serão adicionados no cabeçalho da foto
		// for (int j = 0; j < poss; j++) {
		// if ((apt.get(j).getPrecision() > 0.5)
		// && (apt.get(j).getSufix().equalsIgnoreCase("TIME"))) {
		// possibleTags.add(apt.get(j).getValue());
		// }
		// if (apt.get(j).getSufix().equalsIgnoreCase("NEAR")) {
		// possibleTags.add(apt.get(j).getValue());
		// }
		// System.out.println("Possible Tag " + j);
		// System.out.println(apt.get(j).getValue());
		// System.out.println(apt.get(j).getPrecision());
		// System.out.println(apt.get(j).getSufix());
		//
		// }
		// td.setFriends(apt);

		// *************** FACEBOOK *********************//

		apt = new ArrayList<PossibleTag>();

		String[] nearWiki = new String[10];
		if (currentPhoto.get(i).getNearByWikiObject() != null) {
			Iterator itWiki = currentPhoto.get(i).getNearByWikiObject()
					.iterator();
			// String nearWiki = "";
			int j = 0;
			while (itWiki.hasNext()) {
				Wiki art = (Wiki) itWiki.next();
				// if(art.getDistance())
				nearWiki[j] = art.getTitle();
				System.out.println("Objetos Proximos: " + nearWiki[j]);
				System.out.println("Distancia :" + art.getDistance());
				pt.setPrecision(1 / (1 + art.getDistance()));
				pt.setSufix("NEAR");
				pt.setValue(nearWiki[j]);
				apt.add(pt);
				pt = new PossibleTag();
				j++;
				// photoIPTC.addIPTCKeyword(nearWiki);
			}

		} else {
			Iterator itWiki = currentPhoto.get(i).getNearByWikiObject()
					.iterator();
			// String nearWiki = "";
			int j = 0;
			while (itWiki.hasNext()) {
				Wiki art = (Wiki) itWiki.next();
				// if(art.getDistance())
				nearWiki[j] = art.getTitle();
				System.out.println("Objetos Proximos: " + nearWiki[j]);
				System.out.println("Distancia :" + art.getDistance());
				pt.setPrecision(0);
				pt.setSufix("NEAR");
				pt.setValue(nearWiki[j]);
				apt.add(pt);
				pt = new PossibleTag();
				j++;
			}
		}
		ArrayList<String> wiki = new ArrayList<String>();
		for (int j = 0; j < nearWiki.length; j++) {
			wiki.add(nearWiki[i]);
		}
		td.setNearWiki(apt);
		// td1.setNearWiki(wikiLocals);

		String city = "";
		String country = "";
		if (currentPhoto.get(i).getAddress() != null) {
			if (currentPhoto.get(i).getAddress().getNameCity() != null) {
				city = currentPhoto.get(i).getAddress().getNameCity();
				pt.setPrecision(1);
				pt.setSufix("LOCALIZATION");
				pt.setValue(city);
				td.setCity(pt);
				pt = new PossibleTag();
				System.out.println("Nome da Cidade: " + city);
			}
			if (currentPhoto.get(i).getAddress().getNameCountry() != null) {
				country = currentPhoto.get(i).getAddress().getNameCountry();
				pt.setPrecision(1);
				pt.setSufix("LOCALIZATION");
				pt.setValue(country);
				td.setCountry(pt);
				pt = new PossibleTag();
				System.out.println("Nome do Pais: " + country);
			}
			if (currentPhoto.get(i).getAddress().getNameRoad() != null) {
				pt.setPrecision(1);
				pt.setSufix("LOCALIZATION");
				pt.setValue(currentPhoto.get(i).getAddress().getNameRoad());
				td.setRoad(pt);
				pt = new PossibleTag();
				System.out.println("Estrada: "
						+ currentPhoto.get(i).getAddress().getNameRoad());
			} else {
				pt.setPrecision(0);
				pt.setSufix("LOCALIZATION");
				pt.setValue("...");
				td.setRoad(pt);
				pt = new PossibleTag();
			}
		}
		if (currentPhoto.get(i).getSeason() != null) {
			possibleTags.add(currentPhoto.get(i).getSeason());
			pt.setPrecision(1);
			pt.setSufix("SEASON");
			pt.setValue(currentPhoto.get(i).getSeason());
			td.setSeason(pt);
			pt = new PossibleTag();
			System.out.println("Estacao: " + currentPhoto.get(i).getSeason());
		}

		EarthTools_SunRiseSet esrs = new EarthTools_SunRiseSet();
		esrs.getLightStatusPhotos(currentPhoto.get(i), currentPhoto.get(i)
				.getDateTime());
		esrs.getPartOfDay_Photos(currentPhoto.get(i));

		String partOfDay = currentPhoto.get(i).getPartOfDay();
		possibleTags.add(currentPhoto.get(i).getPartOfDay());
		pt.setPrecision(1);
		pt.setSufix("LIGHT");
		pt.setValue(partOfDay);
		td.setPartOfDay(pt);
		pt = new PossibleTag();
		System.out.println("Parte do dia: "
				+ currentPhoto.get(i).getPartOfDay());

		String sunLight = currentPhoto.get(i).getLightStatus();
		possibleTags.add(currentPhoto.get(i).getLightStatus());
		pt.setPrecision(1);
		pt.setSufix("LIGHT");
		pt.setValue(sunLight);
		td.setSunLight(pt);
		System.out.println("LightStatus: "
				+ currentPhoto.get(i).getLightStatus());

		td.setWikimapia(Wikimapia.Wikimapia(latitude2, longitude2));

		PhotoIPTC photoiptc = new PhotoIPTC(selectedFile.get(i));
		photoIPTC.add(photoiptc);
		return td;
	}

	// private static File selectFile() {
	// JFileChooser chooser = new JFileChooser();
	// chooser.setFileFilter(new FileNameExtensionFilter("JPG Images", "jpg"));
	// int returnVal = chooser.showOpenDialog(null);
	// if (returnVal != JFileChooser.APPROVE_OPTION) {
	// throw new RuntimeException("User interrupted the operation");
	// }
	// return chooser.getSelectedFile();
	// }

	public static void ordenar(ArrayList<Precision> highPrecision,
			ArrayList<Precision> mediumPrecision, int i) {
		Precision pr = new Precision();
		try {
			if (tagsData.get(i).getCity().getPrecision() >= 0.7) {
				pr.setValue(tagsData.get(i).getCity().getValue());
				pr.setPrecision(tagsData.get(i).getCity().getPrecision());
				highPrecision.add(pr);
				pr = new Precision();
			} else if (tagsData.get(i).getCity().getPrecision() >= 0.5) {
				pr.setValue(tagsData.get(i).getCity().getValue());
				pr.setPrecision(tagsData.get(i).getCity().getPrecision());
				mediumPrecision.add(pr);
				pr = new Precision();
			}
		} catch (NullPointerException ex) {

		}
		try {
			if (tagsData.get(i).getCountry().getPrecision() >= 0.7) {
				pr.setValue(tagsData.get(i).getCountry().getValue());
				pr.setPrecision(tagsData.get(i).getCountry().getPrecision());
				highPrecision.add(pr);
				pr = new Precision();
			} else if (tagsData.get(i).getCountry().getPrecision() >= 0.5) {
				pr.setValue(tagsData.get(i).getCountry().getValue());
				pr.setPrecision(tagsData.get(i).getCountry().getPrecision());
				mediumPrecision.add(pr);
				pr = new Precision();
			}
		} catch (NullPointerException ex) {

		}
		for (int j = 0; j < tagsData.get(i).getWikimapia().size(); j++) {
			if (tagsData.get(i).getWikimapia().get(j).getPrecision() >= 0.7) {
				pr.setValue(tagsData.get(i).getWikimapia().get(j).getValue());
				pr.setPrecision(tagsData.get(i).getWikimapia().get(j)
						.getPrecision());
				highPrecision.add(pr);
				pr = new Precision();
			} else if (tagsData.get(i).getCity().getPrecision() >= 0.5) {
				pr.setValue(tagsData.get(i).getWikimapia().get(j).getValue());
				pr.setPrecision(tagsData.get(i).getWikimapia().get(j)
						.getPrecision());
				mediumPrecision.add(pr);
				pr = new Precision();
			}
		}

		// ************** FACEBOOK ******************//

		// for (int j = 0; j < tagsData.get(i).getFriends().size(); j++) {
		// if (tagsData.get(i).getFriends().get(j).getPrecision() >= 0.7) {
		// pr.setValue(tagsData.get(i).getFriends().get(j).getValue());
		// pr.setPrecision(tagsData.get(i).getFriends().get(j)
		// .getPrecision());
		// highPrecision.add(pr);
		// pr = new Precision();
		// } else if (tagsData.get(i).getFriends().get(j).getPrecision() >= 0.5)
		// {
		// pr.setValue(tagsData.get(i).getFriends().get(j).getValue());
		// pr.setPrecision(tagsData.get(i).getFriends().get(j)
		// .getPrecision());
		// mediumPrecision.add(pr);
		// pr = new Precision();
		// }
		// }

		// ************** FACEBOOK ******************//

		for (int j = 0; j < tagsData.get(i).getNearWiki().size(); j++) {
			if (tagsData.get(i).getNearWiki().get(j).getPrecision() >= 0.7) {
				pr.setValue(tagsData.get(i).getNearWiki().get(j).getValue());
				pr.setPrecision(tagsData.get(i).getNearWiki().get(j)
						.getPrecision());
				highPrecision.add(pr);
				pr = new Precision();
			} else if (tagsData.get(i).getNearWiki().get(j).getPrecision() >= 0.5) {
				pr.setValue(tagsData.get(i).getNearWiki().get(j).getValue());
				pr.setPrecision(tagsData.get(i).getNearWiki().get(j)
						.getPrecision());
				mediumPrecision.add(pr);
				pr = new Precision();
			}
		}
		if (tagsData.get(i).getSeason().getPrecision() >= 0.7) {
			pr.setValue(tagsData.get(i).getSeason().getValue());
			pr.setPrecision(tagsData.get(i).getSeason().getPrecision());
			highPrecision.add(pr);
			pr = new Precision();
		} else if (tagsData.get(i).getSeason().getPrecision() >= 0.5) {
			pr.setValue(tagsData.get(i).getSeason().getValue());
			pr.setPrecision(tagsData.get(i).getSeason().getPrecision());
			mediumPrecision.add(pr);
			pr = new Precision();
		}
		if (tagsData.get(i).getDay().getPrecision() >= 0.7) {
			pr.setValue(tagsData.get(i).getDay().getValue());
			pr.setPrecision(tagsData.get(i).getDay().getPrecision());
			highPrecision.add(pr);
			pr = new Precision();
		} else if (tagsData.get(i).getDay().getPrecision() >= 0.5) {
			pr.setValue(tagsData.get(i).getDay().getValue());
			pr.setPrecision(tagsData.get(i).getDay().getPrecision());
			mediumPrecision.add(pr);
			pr = new Precision();
		}
		if (tagsData.get(i).getSunLight().getPrecision() >= 0.7) {
			pr.setValue(tagsData.get(i).getSunLight().getValue());
			pr.setPrecision(tagsData.get(i).getSunLight().getPrecision());
			highPrecision.add(pr);
			pr = new Precision();
		} else if (tagsData.get(i).getSunLight().getPrecision() >= 0.5) {
			pr.setValue(tagsData.get(i).getSunLight().getValue());
			pr.setPrecision(tagsData.get(i).getSunLight().getPrecision());
			mediumPrecision.add(pr);
			pr = new Precision();
		}
		if (tagsData.get(i).getTemperature().getPrecision() >= 0.7) {
			pr.setValue(tagsData.get(i).getTemperature().getValue());
			pr.setPrecision(tagsData.get(i).getTemperature().getPrecision());
			highPrecision.add(pr);
			pr = new Precision();
		} else if (tagsData.get(i).getTemperature().getPrecision() >= 0.5) {
			pr.setValue(tagsData.get(i).getTemperature().getValue());
			pr.setPrecision(tagsData.get(i).getTemperature().getPrecision());
			mediumPrecision.add(pr);
			pr = new Precision();
		}
		if (tagsData.get(i).getWeather() != null) {
			if (tagsData.get(i).getWeather().getPrecision() >= 0.7) {
				pr.setValue(tagsData.get(i).getWeather().getValue());
				pr.setPrecision(tagsData.get(i).getWeather().getPrecision());
				highPrecision.add(pr);
			} else if (tagsData.get(i).getWeather().getPrecision() >= 0.5) {
				pr.setValue(tagsData.get(i).getWeather().getValue());
				pr.setPrecision(tagsData.get(i).getWeather().getPrecision());
				mediumPrecision.add(pr);
			}
		}

		mergeSort_srt(highPrecision, 0, highPrecision.size() - 1);
		mergeSort_srt(mediumPrecision, 0, mediumPrecision.size() - 1);
	}

	public static void setarTags(InterfaceTeste it2,
			ArrayList<Precision> highPrecision,
			ArrayList<Precision> mediumPrecision) {
		int highSize = highPrecision.size();
		int mediumSize = mediumPrecision.size();
		if (highSize >= 12) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
			it2.setTextjLabel53(highPrecision.get(6).getValue());
			it2.setTextjLabel54(highPrecision.get(7).getValue());
			it2.setTextjLabel55(highPrecision.get(8).getValue());
			it2.setTextjLabel56(highPrecision.get(9).getValue());
			it2.setTextjLabel57(highPrecision.get(10).getValue());
			it2.setTextjLabel58(highPrecision.get(11).getValue());
		} else if (highSize == 11) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
			it2.setTextjLabel53(highPrecision.get(6).getValue());
			it2.setTextjLabel54(highPrecision.get(7).getValue());
			it2.setTextjLabel55(highPrecision.get(8).getValue());
			it2.setTextjLabel56(highPrecision.get(9).getValue());
			it2.setTextjLabel57(highPrecision.get(10).getValue());
		} else if (highSize == 10) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
			it2.setTextjLabel53(highPrecision.get(6).getValue());
			it2.setTextjLabel54(highPrecision.get(7).getValue());
			it2.setTextjLabel55(highPrecision.get(8).getValue());
			it2.setTextjLabel56(highPrecision.get(9).getValue());
		} else if (highSize == 9) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
			it2.setTextjLabel53(highPrecision.get(6).getValue());
			it2.setTextjLabel54(highPrecision.get(7).getValue());
			it2.setTextjLabel55(highPrecision.get(8).getValue());
		} else if (highSize == 8) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
			it2.setTextjLabel53(highPrecision.get(6).getValue());
			it2.setTextjLabel54(highPrecision.get(7).getValue());
		} else if (highSize == 7) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
			it2.setTextjLabel53(highPrecision.get(6).getValue());
		} else if (highSize == 6) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
			it2.setTextjLabel52(highPrecision.get(5).getValue());
		} else if (highSize == 5) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
			it2.setTextjLabel51(highPrecision.get(4).getValue());
		} else if (highSize == 4) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
			it2.setTextjLabel50(highPrecision.get(3).getValue());
		} else if (highSize == 3) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
			it2.setTextjLabel49(highPrecision.get(2).getValue());
		} else if (highSize == 2) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
			it2.setTextjLabel48(highPrecision.get(1).getValue());
		} else if (highSize == 1) {
			it2.setTextjLabel47(highPrecision.get(0).getValue());
		} else if (highSize == 0) {
			it2.setHighReady();
		}
		if (mediumSize >= 12) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
			it2.setTextjLabel65(mediumPrecision.get(6).getValue());
			it2.setTextjLabel66(mediumPrecision.get(7).getValue());
			it2.setTextjLabel67(mediumPrecision.get(8).getValue());
			it2.setTextjLabel68(mediumPrecision.get(9).getValue());
			it2.setTextjLabel69(mediumPrecision.get(10).getValue());
			it2.setTextjLabel70(mediumPrecision.get(11).getValue());
		} else if (mediumSize == 11) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
			it2.setTextjLabel65(mediumPrecision.get(6).getValue());
			it2.setTextjLabel66(mediumPrecision.get(7).getValue());
			it2.setTextjLabel67(mediumPrecision.get(8).getValue());
			it2.setTextjLabel68(mediumPrecision.get(9).getValue());
			it2.setTextjLabel69(mediumPrecision.get(10).getValue());
		} else if (mediumSize == 10) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
			it2.setTextjLabel65(mediumPrecision.get(6).getValue());
			it2.setTextjLabel66(mediumPrecision.get(7).getValue());
			it2.setTextjLabel67(mediumPrecision.get(8).getValue());
			it2.setTextjLabel68(mediumPrecision.get(9).getValue());
		} else if (mediumSize == 9) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
			it2.setTextjLabel65(mediumPrecision.get(6).getValue());
			it2.setTextjLabel66(mediumPrecision.get(7).getValue());
			it2.setTextjLabel67(mediumPrecision.get(8).getValue());
		} else if (mediumSize == 8) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
			it2.setTextjLabel65(mediumPrecision.get(6).getValue());
			it2.setTextjLabel66(mediumPrecision.get(7).getValue());
		} else if (mediumSize == 7) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
			it2.setTextjLabel65(mediumPrecision.get(6).getValue());
		} else if (mediumSize == 6) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
			it2.setTextjLabel64(mediumPrecision.get(5).getValue());
		} else if (mediumSize == 5) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
			it2.setTextjLabel63(mediumPrecision.get(4).getValue());
		} else if (mediumSize == 4) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
			it2.setTextjLabel62(mediumPrecision.get(3).getValue());
		} else if (mediumSize == 3) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
			it2.setTextjLabel61(mediumPrecision.get(2).getValue());
		} else if (mediumSize == 2) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
			it2.setTextjLabel60(mediumPrecision.get(1).getValue());
		} else if (mediumSize == 1) {
			it2.setTextjLabel59(mediumPrecision.get(0).getValue());
		} else if (mediumSize == 0) {
			it2.setMediumReady();
		}
	}

	public static void setarWords(ArrayList<Precision> highPrecision,
			ArrayList<Precision> mediumPrecision) {
		ArrayList<String> al = new ArrayList<String>();
		for (int i = 0; i < highPrecision.size(); i++) {
			al.add(highPrecision.get(i).getValue());
		}
		wordsHigh.add(al);
		al = new ArrayList<String>();
		for (int i = 0; i < mediumPrecision.size(); i++) {
			al.add(mediumPrecision.get(i).getValue());
		}
		wordsMedium.add(al);
	}

	public static void setarFotos(InterfaceTeste it2,
			ArrayList<ImageIcon> icon25) {
		int size = icon25.size();
		int dif = size - 16;
		int x = 0;
		int y = 16;
		if (dif > 0) {
			java.awt.GridBagConstraints gridBagConstraints;
			javax.swing.JLabel jLabel;
			for (int i = 0; i < dif; i++) {
				jLabel = new javax.swing.JLabel(icon25.get(i + 16));
				if (i > 0) {
					if (x == 0) {
						x = 5;
					} else if (x == 5) {
						x = 10;
					} else if (x == 10) {
						x = 15;
					} else if (x == 15) {
						x = 0;
						y += 4;
					}
				}
				gridBagConstraints = new java.awt.GridBagConstraints();
				gridBagConstraints.gridx = x;
				gridBagConstraints.gridy = y;
				gridBagConstraints.gridwidth = 5;
				gridBagConstraints.gridheight = 4;
				gridBagConstraints.insets = new java.awt.Insets(15, 17, 15, 17);
				it2.addjPanel6(jLabel, gridBagConstraints);
			}
		} else {
			if (size == 16) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
				it2.setIconjLabel15(icon25.get(10));
				it2.setIconjLabel16(icon25.get(11));
				it2.setIconjLabel17(icon25.get(12));
				it2.setIconjLabel18(icon25.get(13));
				it2.setIconjLabel19(icon25.get(14));
				it2.setIconjLabel20(icon25.get(15));
			} else if (size == 15) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
				it2.setIconjLabel15(icon25.get(10));
				it2.setIconjLabel16(icon25.get(11));
				it2.setIconjLabel17(icon25.get(12));
				it2.setIconjLabel18(icon25.get(13));
				it2.setIconjLabel19(icon25.get(14));
			} else if (size == 14) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
				it2.setIconjLabel15(icon25.get(10));
				it2.setIconjLabel16(icon25.get(11));
				it2.setIconjLabel17(icon25.get(12));
				it2.setIconjLabel18(icon25.get(13));
			} else if (size == 13) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
				it2.setIconjLabel15(icon25.get(10));
				it2.setIconjLabel16(icon25.get(11));
				it2.setIconjLabel17(icon25.get(12));
			} else if (size == 12) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
				it2.setIconjLabel15(icon25.get(10));
				it2.setIconjLabel16(icon25.get(11));
			} else if (size == 11) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
				it2.setIconjLabel15(icon25.get(10));
			} else if (size == 10) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
				it2.setIconjLabel14(icon25.get(9));
			} else if (size == 9) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
				it2.setIconjLabel13(icon25.get(8));
			} else if (size == 8) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
				it2.setIconjLabel12(icon25.get(7));
			} else if (size == 7) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
				it2.setIconjLabel11(icon25.get(6));
			} else if (size == 6) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
				it2.setIconjLabel10(icon25.get(5));
			} else if (size == 5) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
				it2.setIconjLabel9(icon25.get(4));
			} else if (size == 4) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
				it2.setIconjLabel8(icon25.get(3));
			} else if (size == 3) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
				it2.setIconjLabel7(icon25.get(2));
			} else if (size == 2) {
				it2.setIconjLabel5(icon25.get(0));
				it2.setIconjLabel6(icon25.get(1));
			} else if (size == 1) {
				it2.setIconjLabel5(icon25.get(0));
			}
		}
	}

	public static void setarFotosSlider(InterfaceTeste it2,
			ArrayList<ImageIcon> icon25, int value) {
		int size = icon25.size();
		if (size > 1) {
			if (value == size - 3) {
				it2.setIconjLabel72(icon25.get(value));
				it2.setIconjLabel73(icon25.get(value + 1));
				it2.setIconjLabel74(icon25.get(value + 2));
				it2.setIconjLabel75(icon25.get(0));
			} else if (value == size - 2) {
				it2.setIconjLabel72(icon25.get(value));
				it2.setIconjLabel73(icon25.get(value + 1));
				it2.setIconjLabel74(icon25.get(0));
				it2.setIconjLabel75(icon25.get(1));
			} else if (value == size - 1) {
				it2.setIconjLabel72(icon25.get(value));
				it2.setIconjLabel73(icon25.get(0));
				it2.setIconjLabel74(icon25.get(1));
				it2.setIconjLabel75(icon25.get(2));
			} else {
				it2.setIconjLabel72(icon25.get(value));
				it2.setIconjLabel73(icon25.get(value + 1));
				it2.setIconjLabel74(icon25.get(value + 2));
				it2.setIconjLabel75(icon25.get(value + 3));
			}
		} else if (size == 3) {
			if (value == 0) {
				it2.setIconjLabel72(icon25.get(0));
				it2.setIconjLabel73(icon25.get(1));
				it2.setIconjLabel74(icon25.get(2));
			} else if (value == 1) {
				it2.setIconjLabel72(icon25.get(1));
				it2.setIconjLabel73(icon25.get(2));
				it2.setIconjLabel74(icon25.get(0));
			} else {
				it2.setIconjLabel72(icon25.get(2));
				it2.setIconjLabel73(icon25.get(0));
				it2.setIconjLabel74(icon25.get(1));
			}
		} else if (size == 2) {
			if (value == 0) {
				it2.setIconjLabel72(icon25.get(0));
				it2.setIconjLabel73(icon25.get(1));
			} else {
				it2.setIconjLabel72(icon25.get(1));
				it2.setIconjLabel73(icon25.get(0));
			}
		} else if (size == 1) {
			it2.setIconjLabel72(icon25.get(0));
		}
	}

	public static void fotoValidada(ArrayList<ImageIcon> icon25, int i)
			throws IOException {
		File file = new File("images/ok-icon_17-1009133509.jpg");
		BufferedImage thumb = Thumbnails.of(file).scale(0.10).asBufferedImage();
		ImageIcon ic = new ImageIcon(thumb);
		icon25.set(i, ic);
	}

	public static void mergeSort_srt(ArrayList<Precision> pr, int lo, int n) {
		int low = lo;
		int high = n;
		if (low >= high) {
			return;
		}
		int middle = (low + high) / 2;
		mergeSort_srt(pr, low, middle);
		mergeSort_srt(pr, middle + 1, high);
		int end_low = middle;
		int start_high = middle + 1;
		while ((lo <= end_low) && (start_high <= high)) {
			if (pr.get(start_high).getPrecision() < pr.get(low).getPrecision()) {
				low++;
			} else {
				Precision Temp = pr.get(start_high);
				for (int k = start_high - 1; k >= low; k--) {
					pr.set(k + 1, pr.get(k));
				}
				pr.set(low, Temp);
				low++;
				end_low++;
				start_high++;
			}
		}
	}

	public static void facebookImages(Interface it) throws IOException {
		File file = new File("facebooklogo.jpg");
		BufferedImage thumb = Thumbnails.of(file).scale(0.30).asBufferedImage();
		ImageIcon ic = new ImageIcon(thumb);
		it.setIconjLabel1(ic);
		file = new File("facebook_logo2.png");
		thumb = Thumbnails.of(file).scale(0.30).asBufferedImage();
		ic = new ImageIcon(thumb);
		it.setIconjLabel2(ic);
	}

	public void run() {

		for (int i = 1; i < selectedFile.size(); i++) {
			try {
				tagsData.add(inference(i, name));
			} catch (ImageReadException ex) {
				Logger.getLogger(Principal.class.getName()).log(Level.SEVERE,
						null, ex);
			} catch (IOException ex) {
				Logger.getLogger(Principal.class.getName()).log(Level.SEVERE,
						null, ex);
			} catch (ParseException ex) {
				Logger.getLogger(Principal.class.getName()).log(Level.SEVERE,
						null, ex);
			} catch (JSONException ex) {
				Logger.getLogger(Principal.class.getName()).log(Level.SEVERE,
						null, ex);
			} catch (ImageWriteException ex) {
				Logger.getLogger(Principal.class.getName()).log(Level.SEVERE,
						null, ex);
			}

		}
	}
}
